home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2003 September / PC Answers September 2003.iso / Software / freeware / pixeltoolbox / Setup.exe / Main / PixelToolbox.exe / PixelToolbox.dxr / Scripts_26_eraser tools.ls < prev    next >
Encoding:
Text File  |  2002-06-08  |  5.0 KB  |  79 lines

  1. global gVariable, gCast, gSize, gSecondColor, gEraserMask, gEraserSize, myCurrentImage, myCurrentPreview
  2.  
  3. on tool1PxEraser
  4.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  5.   coordinateList = []
  6.   coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  7.   coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  8.   member(gSize & "x" & gSize, gCast).image.setPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, gSecondColor)
  9.   updateStage()
  10.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  11.   myCurrentPreview = duplicate(member("preview", gCast).image)
  12.   repeat while the mouseDown
  13.     if (((the mouseH - sprite(1).left) * 2 / gVariable / 2) = getAt(coordinateList, count(coordinateList) - 1)) and (((the mouseV - sprite(1).top) * 2 / gVariable / 2) = getAt(coordinateList, count(coordinateList))) then
  14.       myCurrentImage.setPixel((the mouseH - sprite(1).left) * 2 / gVariable / 2, (the mouseV - sprite(1).top) * 2 / gVariable / 2, gSecondColor)
  15.     else
  16.       coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  17.       coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  18.       myCurrentImage.draw(getAt(coordinateList, 1), getAt(coordinateList, 2), getAt(coordinateList, 3), getAt(coordinateList, 4), [#shapeType: #line, #lineSize: 1, #color: gSecondColor])
  19.       deleteAt(coordinateList, 1)
  20.       deleteAt(coordinateList, 1)
  21.     end if
  22.     member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  23.     updateStage()
  24.     put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  25.     put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  26.     fnUpdatePreview()
  27.   end repeat
  28.   coordinateList = VOID
  29.   sprite(35).pState = 0
  30.   sendSprite(35, #setMember)
  31.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  32.   myCurrentImage = VOID
  33.   myCurrentPreview = VOID
  34.   put EMPTY into field "location status X"
  35.   put EMPTY into field "location status Y"
  36. end
  37.  
  38. on toolEraser
  39.   member("state1 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  40.   coordinateList = []
  41.   coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  42.   coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  43.   member(gSize & "x" & gSize, gCast).image.copyPixels(member("2nd Color", gCast).image, rect(((the mouseH - sprite(1).left) * 2 / gVariable / 2) - 4, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) - 4, ((the mouseH - sprite(1).left) * 2 / gVariable / 2) + 5, ((the mouseV - sprite(1).top) * 2 / gVariable / 2) + 5), rect(0, 0, 9, 9), [#maskImage: member(gEraserMask).image.createMask()])
  44.   sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
  45.   updateStage()
  46.   myCurrentImage = duplicate(member(gSize & "x" & gSize, gCast).image)
  47.   myCurrentPreview = duplicate(member("preview", gCast).image)
  48.   repeat while the mouseDown
  49.     if (getAt(coordinateList, 1) = ((the mouseH - sprite(1).left) * 2 / gVariable / 2)) and (getAt(coordinateList, 2) = ((the mouseV - sprite(1).top) * 2 / gVariable / 2)) then
  50.       nothing()
  51.     else
  52.       coordinateList.add((the mouseH - sprite(1).left) * 2 / gVariable / 2)
  53.       coordinateList.add((the mouseV - sprite(1).top) * 2 / gVariable / 2)
  54.       numSteps = float(sqrt(power(getAt(coordinateList, 1) - getAt(coordinateList, 3), 2) + power(getAt(coordinateList, 2) - getAt(coordinateList, 4), 2))) + 1
  55.       repeat with i = 1 to numSteps
  56.         l = (getAt(coordinateList, 1) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 3) * (float(i) / numSteps))
  57.         t = (getAt(coordinateList, 2) * (numSteps - float(i)) / numSteps) + (getAt(coordinateList, 4) * (float(i) / numSteps))
  58.         myCurrentImage.copyPixels(member("2nd Color", gCast).image, rect(l - 4, t - 4, l + 5, t + 5), rect(0, 0, 9, 9), [#maskImage: member(gEraserMask).image.createMask()])
  59.       end repeat
  60.       deleteAt(coordinateList, 1)
  61.       deleteAt(coordinateList, 1)
  62.       member(gSize & "x" & gSize, gCast).image.copyPixels(myCurrentImage, myCurrentImage.rect, myCurrentImage.rect)
  63.       sprite(8).rect = rect(the mouseH - (gEraserSize * gVariable / 2), the mouseV - (gEraserSize * gVariable / 2), the mouseH + (gEraserSize * gVariable / 2), the mouseV + (gEraserSize * gVariable / 2))
  64.       updateStage()
  65.     end if
  66.     put (the mouseH - sprite(1).left) * 2 / gVariable / 2 into field "location status X"
  67.     put (the mouseV - sprite(1).top) * 2 / gVariable / 2 into field "location status Y"
  68.     fnUpdatePreview()
  69.   end repeat
  70.   coordinateList = VOID
  71.   sprite(35).pState = 0
  72.   sendSprite(35, #setMember)
  73.   member("state2 - " & gSize, gCast).image = member(gSize & "x" & gSize, gCast).image
  74.   myCurrentImage = VOID
  75.   myCurrentPreview = VOID
  76.   put EMPTY into field "location status X"
  77.   put EMPTY into field "location status Y"
  78. end
  79.